package com.ycxy.springbootmybatis.controller;

import com.ycxy.springbootmybatis.entity.User;
import com.ycxy.springbootmybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/getUser/{id}")
    public User getUserById(@PathVariable("id") Integer id) {
        return userService.getUserById(id);
    }

    @RequestMapping("/updateUser/{id}/{username}")
    public boolean UpdateUser(@PathVariable("id") int id,@PathVariable("username") String username) {
        return userService.UpdateUser(id,username)!=null;
    }

    @RequestMapping("/deleteUser/{id}")
    public int removeUser(@PathVariable("id") int id){
        return userService.deleteUser(id);
    }
}
